package com.captain.leetcode;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author captain
 * @Des
 * @Date 2021/7/24 23:27
 */
public class 零钱兑换322 {

    public static void main(String[] args) {
        int[] arr = new int[]{1, 5, 20, 25};
        System.out.println(new 零钱兑换322().coinChange(arr, 41));
    }

    public int coinChange(int[] coins, int n) {
        List<Integer> list = Arrays
                .stream(coins)
                .boxed()
                .collect(Collectors.toList());
        return coins(list, n);
    }

    private int min = 0;

    private int coins(List<Integer> coinsList, int n) {
        if (n < 1) return Integer.MAX_VALUE;
        if (coinsList.contains(n)) return 1;
        for (Integer nn : coinsList) {
            min = Math.min(coins(coinsList, nn), min);
        }
        return min == 0 ? -1 : min;
    }

}
